package learn_concurrent._1;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class T19 {
	final static Logger logger = LoggerFactory.getLogger(T19.class);

	public static void main(String[] args) throws InterruptedException {
		Thread t1 = new Thread(() -> {
			logger.debug("running");
		}, "t1");

		Thread t2 = new Thread(() -> {
			while (true) {
			}
		}, "t2");
		t2.start();

		Thread t3 = new Thread(() -> {
			synchronized (T19.class) {
				try {
					Thread.sleep(100000);
				} catch (InterruptedException e) {
					e.printStackTrace();
				}
			}
		}, "t3");
		t3.start();

		Thread t4 = new Thread(() -> {
			try {
				t2.join();
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
		}, "t4");
		t4.start();

		Thread t5 = new Thread(() -> {
			synchronized (T19.class) {
				try {
					Thread.sleep(100000);
				} catch (InterruptedException e) {
					e.printStackTrace();
				}
			}
		}, "t5");
		t5.start();

		Thread t6 = new Thread(() -> {}, "t6");
		t6.start();

		// -----------------------------
		Thread.sleep(1000);
		logger.debug("{} : NEW {}", t1.getName(), t1.getState());
		logger.debug("{} : RUNNABLE {}", t2.getName(), t2.getState());
		logger.debug("{} : TIMED_WAITING {}", t3.getName(), t3.getState());
		logger.debug("{} : WAITING {}", t4.getName(), t4.getState());
		logger.debug("{} : BLOCKED {}", t5.getName(), t5.getState());
		logger.debug("{} : TERMINATED {}", t6.getName(), t6.getState());

	}

}
